package larpplanner.gui;

import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.widgets.Text;

import com.cloudgarden.resource.SWTResourceManager;

public abstract class GUIUtil {

    public static void setHintText(final Text textWidget) {

        final String hint = textWidget.getText();
        textWidget.setForeground(SWTResourceManager.getColor(146, 147, 147));
        
        textWidget.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent evt) {
                if(textWidget.getText().equals("")) {
                    textWidget.setText(hint);
                    textWidget.setForeground(SWTResourceManager.getColor(146, 147, 147));
                }
            }
            public void focusGained(FocusEvent evt) {
                if(textWidget.getText().equals(hint)) {
                    textWidget.setText("");
                    textWidget.setForeground(SWTResourceManager.getColor(0, 0, 0));
                }
            }
        });
        
        
    }
}
